version: "3.9"

networks:
  proxy: # docker network create --driver=overlay --internal=false --attachable proxy
    driver: overlay
    attachable: true
    internal: false
    name: proxy

volumes:
  traefik-letsencrypt-volume:

services:
  traefik:
    image: traefik:v2.4.9
    restart: always
    container_name: server-traefik
    networks:
      - proxy
    ports:
      - target: 80
        published: 80
        mode: host
      - target: 443
        published: 443
        mode: host
    volumes:
      # traefik needs the docker socket in order to work properly
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - traefik-letsencrypt-volume:/letsencrypt
    labels:
      - traefik.enable=true
      - traefik.docker.network=proxy
      - traefik.http.routers.dashboard.rule=Host(`traefik.epic-type.online`)
      - traefik.http.routers.wildcard-certs.tls.domains[0].main=epic-type.online
      - traefik.http.routers.wildcard-certs.tls.domains[0].sans=*.epic-type.online
      - traefik.http.routers.dashboard.service=api@internal
      - traefik.http.routers.dashboard.middlewares=auth
      - traefik.http.middlewares.auth.basicauth.users=epictype:$$apr1$$L7buz6zi$$qsgRaFkdyZq0qelWS99v.0
      - traefik.http.routers.dashboard.entrypoints=websecure
      - traefik.http.routers.dashboard.tls=true
      - traefik.http.routers.dashboard.tls.certresolver=letsencrypt
      - traefik.http.services.dashboard-service.loadbalancer.server.port=888
    command:
      - --api=true
      - --api.dashboard=true
      - --api.debug=false
      - --providers.docker=true
      - --providers.docker.endpoint=unix:///var/run/docker.sock
      - --providers.docker.swarmMode=false
      - --providers.docker.exposedbydefault=false
      - --log.filePath=/traefik.log
      - --log.level=INFO
      - --accesslog=false
      - --entryPoints.web.address=:80
      - --entrypoints.web.http.redirections.entrypoint.to=websecure
      - --entrypoints.web.http.redirections.entrypoint.scheme=https
      - --entrypoints.web.http.redirections.entrypoint.permanent=false
      - --entryPoints.websecure.address=:443
      # letsencrypt
      - --certificatesresolvers.letsencrypt.acme.email=DenRus38@hotmail.com
      - --certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json
      # used during the challenge
      - --certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web
